home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / SoundComponents.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  13.7 KB  |  358 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SoundComponents.p
  3.  
  4.      Contains:    Sound Components Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT SoundComponents;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __SOUNDCOMPONENTS__}
  30. {$SETC __SOUNDCOMPONENTS__ := 1}
  31.  
  32. {$I+}
  33. {$SETC SoundComponentsIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __COMPONENTS__}
  43. {$I Components.p}
  44. {$ENDC}
  45. {    MixedMode.p                                                    }
  46.  
  47. {$IFC UNDEFINED __SOUND__}
  48. {$I Sound.p}
  49. {$ENDC}
  50.  
  51. {$PUSH}
  52. {$ALIGN MAC68K}
  53. {$LibExport+}
  54. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  55. { constants}
  56. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  57.  
  58. CONST
  59. {sound component set/get info selectors}
  60.     siVolume                    = 'volu';
  61.     siHardwareVolume            = 'hvol';
  62.     siSpeakerVolume                = 'svol';
  63.     siHeadphoneVolume            = 'pvol';
  64.     siHardwareVolumeSteps        = 'hstp';
  65.     siHeadphoneVolumeSteps        = 'hdst';
  66.     siHardwareMute                = 'hmut';
  67.     siSpeakerMute                = 'smut';
  68.     siHeadphoneMute                = 'pmut';
  69.     siRateMultiplier            = 'rmul';
  70.     siQuality                    = 'qual';
  71. {format types}
  72.     kOffsetBinary                = 'raw ';
  73.     kTwosComplement                = 'twos';
  74.     kMACE3Compression            = 'MAC3';
  75.     kMACE6Compression            = 'MAC6';
  76.  
  77. {quality flags}
  78. {use interpolation in rate conversion}
  79.     kBestQuality                = 0+(1 * (2**(0)));
  80.  
  81. {useful bit masks}
  82.     kInputMask                    = $000000FF;                    {masks off input bits}
  83.     kOutputMask                    = $0000FF00;                    {masks off output bits}
  84.     kOutputShift                = 8;                            {amount output bits are shifted}
  85.     kActionMask                    = $00FF0000;                    {masks off action bits}
  86.     kSoundComponentBits            = $00FFFFFF;
  87.  
  88. {SoundComponentPlaySourceBuffer action flags}
  89.     kSourcePaused                = 0+(1 * (2**(0)));
  90.     kPassThrough                = 0+(1 * (2**(16)));
  91.     kNoSoundComponentChain        = 0+(1 * (2**(17)));
  92. {flags for OpenMixerSoundComponent}
  93.     kNoMixing                    = 0+(1 * (2**(0)));                {don't mix source}
  94.     kNoSampleRateConversion        = 0+(1 * (2**(1)));                {don't convert sample rate (i.e. 11 kHz -> 22 kHz)}
  95.     kNoSampleSizeConversion        = 0+(1 * (2**(2)));                {don't convert sample size (i.e. 16 -> 8)}
  96.     kNoSampleFormatConversion    = 0+(1 * (2**(3)));                {don't convert sample format (i.e. 'twos' -> 'raw ')}
  97.     kNoChannelConversion        = 0+(1 * (2**(4)));                {don't convert stereo/mono}
  98.     kNoDecompression            = 0+(1 * (2**(5)));                {don't decompress (i.e. 'MAC3' -> 'raw ')}
  99.     kNoVolumeConversion            = 0+(1 * (2**(6)));                {don't apply volume}
  100.     kNoRealtimeProcessing        = 0+(1 * (2**(7)));                {won't run at interrupt time}
  101.  
  102. {Audio Component constants}
  103. {Values for whichChannel parameter}
  104.     audioAllChannels            = 0;                            {All channels (usually interpreted as both left and right)}
  105.     audioLeftChannel            = 1;                            {Left channel}
  106.     audioRightChannel            = 2;                            {Right channel}
  107. {Values for mute parameter}
  108.     audioUnmuted                = 0;                            {Device is unmuted}
  109.     audioMuted                    = 1;                            {Device is muted}
  110. {Capabilities flags definitions}
  111.     audioDoesMono                = 0+(1 * (2**(0)));                {Device supports mono output}
  112.     audioDoesStereo                = 0+(1 * (2**(1)));                {Device supports stereo output}
  113.     audioDoesIndependentChannels = 0+(1 * (2**(2)));            {Device supports independent software control of each channel}
  114.  
  115. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  116. { typedefs}
  117. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  118. {ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,}
  119. {with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375}
  120.     
  121. TYPE
  122.     ShortFixed = INTEGER;
  123.  
  124.     SoundComponentDataPtr = ^SoundComponentData;
  125.  
  126.     SoundComponentData = RECORD
  127.         flags:                    LONGINT;
  128.         format:                    OSType;
  129.         numChannels:            INTEGER;
  130.         sampleSize:                INTEGER;
  131.         sampleRate:                UnsignedFixed;
  132.         sampleCount:            LONGINT;
  133.         buffer:                    ^Byte;
  134.         reserved:                LONGINT;
  135.     END;
  136.  
  137.     SoundParamBlockPtr = ^SoundParamBlock;
  138.  
  139.     SoundParamProcPtr = ProcPtr;  { FUNCTION SoundParam(VAR pb: SoundParamBlockPtr): BOOLEAN; }
  140.     SoundParamUPP = UniversalProcPtr;
  141.  
  142.     SoundParamBlock = RECORD
  143.         recordSize:                LONGINT;                                {size of this record in bytes}
  144.         desc:                    SoundComponentData;                        {description of sound buffer}
  145.         rateMultiplier:            UnsignedFixed;                            {rate multiplier to apply to sound}
  146.         leftVolume:                INTEGER;                                {volumes to apply to sound}
  147.         rightVolume:            INTEGER;
  148.         quality:                LONGINT;                                {quality to apply to sound}
  149.         filter:                    ComponentInstance;                        {filter to apply to sound}
  150.         moreRtn:                SoundParamUPP;                            {routine to call to get more data}
  151.         completionRtn:            SoundParamUPP;                            {routine to call when buffer is complete}
  152.         refCon:                    LONGINT;                                {user refcon}
  153.         result:                    INTEGER;                                {result}
  154.     END;
  155.  
  156.     SoundSource = Ptr;
  157.  
  158.     AudioInfo = RECORD
  159.         capabilitiesFlags:        LONGINT;                                {Describes device capabilities}
  160.         reserved:                LONGINT;                                {Reserved by Apple}
  161.         numVolumeSteps:            INTEGER;                                {Number of significant increments between min and max volume}
  162.     END;
  163.  
  164.     AudioInfoPtr = ^AudioInfo;
  165.  
  166. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  167. { functions for sound components}
  168. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  169. {Sound Component dispatch selectors}
  170.  
  171. CONST
  172. {these calls cannot be delegated}
  173.     kSoundComponentInitOutputDeviceSelect = 1;
  174.     kSoundComponentSetSourceSelect = 2;
  175.     kSoundComponentGetSourceSelect = 3;
  176.     kSoundComponentGetSourceDataSelect = 4;
  177.     kSoundComponentSetOutputSelect = 5;
  178.     kDelegatedSoundComponentSelectors = $0100;                    {first selector that can be delegated up the chain}
  179. {these calls can be delegated and have own range}
  180.     kSoundComponentAddSourceSelect = kDelegatedSoundComponentSelectors + 1;
  181.     kSoundComponentRemoveSourceSelect = kDelegatedSoundComponentSelectors + 2;
  182.     kSoundComponentGetInfoSelect = kDelegatedSoundComponentSelectors + 3;
  183.     kSoundComponentSetInfoSelect = kDelegatedSoundComponentSelectors + 4;
  184.     kSoundComponentStartSourceSelect = kDelegatedSoundComponentSelectors + 5;
  185.     kSoundComponentStopSourceSelect = kDelegatedSoundComponentSelectors + 6;
  186.     kSoundComponentPauseSourceSelect = kDelegatedSoundComponentSelectors + 7;
  187.     kSoundComponentPlaySourceBufferSelect = kDelegatedSoundComponentSelectors + 8;
  188.  
  189. {Audio Component selectors}
  190.     kAudioGetVolumeSelect        = 0;
  191.     kAudioSetVolumeSelect        = 1;
  192.     kAudioGetMuteSelect            = 2;
  193.     kAudioSetMuteSelect            = 3;
  194.     kAudioSetToDefaultsSelect    = 4;
  195.     kAudioGetInfoSelect            = 5;
  196.     kAudioGetBassSelect            = 6;
  197.     kAudioSetBassSelect            = 7;
  198.     kAudioGetTrebleSelect        = 8;
  199.     kAudioSetTrebleSelect        = 9;
  200.     kAudioGetOutputDeviceSelect    = 10;
  201.     kAudioMuteOnEventSelect        = 129;
  202.  
  203. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  204. { Sound Manager 3.0 utilities}
  205.  
  206. FUNCTION OpenMixerSoundComponent(outputDescription: SoundComponentDataPtr; outputFlags: LONGINT; VAR mixerComponent: ComponentInstance): OSErr;
  207.     {$IFC NOT GENERATINGCFM}
  208.     INLINE $203C, $0614, $0018, $A800;
  209.     {$ENDC}
  210. FUNCTION CloseMixerSoundComponent(ci: ComponentInstance): OSErr;
  211.     {$IFC NOT GENERATINGCFM}
  212.     INLINE $203C, $0218, $0018, $A800;
  213.     {$ENDC}
  214. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  215. { basic sound component functions}
  216. FUNCTION SoundComponentInitOutputDevice(ti: ComponentInstance; actions: LONGINT): ComponentResult;
  217.     {$IFC NOT GENERATINGCFM}
  218.     INLINE $2F3C, 4, 1, $7000, $A82A;
  219.     {$ENDC}
  220. FUNCTION SoundComponentSetSource(ti: ComponentInstance; sourceID: SoundSource; source: ComponentInstance): ComponentResult;
  221.     {$IFC NOT GENERATINGCFM}
  222.     INLINE $2F3C, 8, 2, $7000, $A82A;
  223.     {$ENDC}
  224. FUNCTION SoundComponentGetSource(ti: ComponentInstance; sourceID: SoundSource; VAR source: ComponentInstance): ComponentResult;
  225.     {$IFC NOT GENERATINGCFM}
  226.     INLINE $2F3C, 8, 3, $7000, $A82A;
  227.     {$ENDC}
  228. FUNCTION SoundComponentGetSourceData(ti: ComponentInstance; VAR sourceData: SoundComponentDataPtr): ComponentResult;
  229.     {$IFC NOT GENERATINGCFM}
  230.     INLINE $2F3C, 4, 4, $7000, $A82A;
  231.     {$ENDC}
  232. FUNCTION SoundComponentSetOutput(ti: ComponentInstance; requested: SoundComponentDataPtr; VAR actual: SoundComponentDataPtr): ComponentResult;
  233.     {$IFC NOT GENERATINGCFM}
  234.     INLINE $2F3C, 8, 5, $7000, $A82A;
  235.     {$ENDC}
  236. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  237. { junction methods for the mixer, must be called at non-interrupt level}
  238. FUNCTION SoundComponentAddSource(ti: ComponentInstance; VAR sourceID: SoundSource): ComponentResult;
  239.     {$IFC NOT GENERATINGCFM}
  240.     INLINE $2F3C, 4, $0101, $7000, $A82A;
  241.     {$ENDC}
  242. FUNCTION SoundComponentRemoveSource(ti: ComponentInstance; sourceID: SoundSource): ComponentResult;
  243.     {$IFC NOT GENERATINGCFM}
  244.     INLINE $2F3C, 4, $0102, $7000, $A82A;
  245.     {$ENDC}
  246. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  247. { info methods}
  248. FUNCTION SoundComponentGetInfo(ti: ComponentInstance; sourceID: SoundSource; selector: OSType; infoPtr: UNIV Ptr): ComponentResult;
  249.     {$IFC NOT GENERATINGCFM}
  250.     INLINE $2F3C, 12, $0103, $7000, $A82A;
  251.     {$ENDC}
  252. FUNCTION SoundComponentSetInfo(ti: ComponentInstance; sourceID: SoundSource; selector: OSType; infoPtr: UNIV Ptr): ComponentResult;
  253.     {$IFC NOT GENERATINGCFM}
  254.     INLINE $2F3C, 12, $0104, $7000, $A82A;
  255.     {$ENDC}
  256. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  257. { control methods}
  258. FUNCTION SoundComponentStartSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  259.     {$IFC NOT GENERATINGCFM}
  260.     INLINE $2F3C, 6, $0105, $7000, $A82A;
  261.     {$ENDC}
  262. FUNCTION SoundComponentStopSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  263.     {$IFC NOT GENERATINGCFM}
  264.     INLINE $2F3C, 6, $0106, $7000, $A82A;
  265.     {$ENDC}
  266. FUNCTION SoundComponentPauseSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  267.     {$IFC NOT GENERATINGCFM}
  268.     INLINE $2F3C, 6, $0107, $7000, $A82A;
  269.     {$ENDC}
  270. FUNCTION SoundComponentPlaySourceBuffer(ti: ComponentInstance; sourceID: SoundSource; pb: SoundParamBlockPtr; actions: LONGINT): ComponentResult;
  271.     {$IFC NOT GENERATINGCFM}
  272.     INLINE $2F3C, 12, $0108, $7000, $A82A;
  273.     {$ENDC}
  274. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  275. { interface for Audio Components}
  276. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  277. {Volume is described as a value between 0 and 1, with 0 indicating minimum
  278.   volume and 1 indicating maximum volume; if the device doesn't support
  279.   software control of volume, then a value of unimpErr is returned, indicating
  280.   that these functions are not supported by the device}
  281. FUNCTION AudioGetVolume(ac: ComponentInstance; whichChannel: INTEGER; VAR volume: ShortFixed): ComponentResult;
  282.     {$IFC NOT GENERATINGCFM}
  283.     INLINE $2F3C, 6, 0, $7000, $A82A;
  284.     {$ENDC}
  285. FUNCTION AudioSetVolume(ac: ComponentInstance; whichChannel: INTEGER; volume: ShortFixed): ComponentResult;
  286.     {$IFC NOT GENERATINGCFM}
  287.     INLINE $2F3C, 4, 1, $7000, $A82A;
  288.     {$ENDC}
  289. {If the device doesn't support software control of mute, then a value of unimpErr is}
  290. {returned, indicating that these functions are not supported by the device}
  291. FUNCTION AudioGetMute(ac: ComponentInstance; whichChannel: INTEGER; VAR mute: INTEGER): ComponentResult;
  292.     {$IFC NOT GENERATINGCFM}
  293.     INLINE $2F3C, 6, 2, $7000, $A82A;
  294.     {$ENDC}
  295. FUNCTION AudioSetMute(ac: ComponentInstance; whichChannel: INTEGER; mute: INTEGER): ComponentResult;
  296.     {$IFC NOT GENERATINGCFM}
  297.     INLINE $2F3C, 4, 3, $7000, $A82A;
  298.     {$ENDC}
  299. {AudioSetToDefaults causes the associated device to reset its volume and mute values}
  300. {(and perhaps other characteristics, e.g. attenuation) to "factory default" settings}
  301. FUNCTION AudioSetToDefaults(ac: ComponentInstance): ComponentResult;
  302.     {$IFC NOT GENERATINGCFM}
  303.     INLINE $2F3C, 0, 4, $7000, $A82A;
  304.     {$ENDC}
  305. {This routine is required; it must be implemented by all audio components}
  306. FUNCTION AudioGetInfo(ac: ComponentInstance; info: AudioInfoPtr): ComponentResult;
  307.     {$IFC NOT GENERATINGCFM}
  308.     INLINE $2F3C, 4, 5, $7000, $A82A;
  309.     {$ENDC}
  310. FUNCTION AudioGetBass(ac: ComponentInstance; whichChannel: INTEGER; VAR bass: INTEGER): ComponentResult;
  311.     {$IFC NOT GENERATINGCFM}
  312.     INLINE $2F3C, 6, 6, $7000, $A82A;
  313.     {$ENDC}
  314. FUNCTION AudioSetBass(ac: ComponentInstance; whichChannel: INTEGER; bass: INTEGER): ComponentResult;
  315.     {$IFC NOT GENERATINGCFM}
  316.     INLINE $2F3C, 4, 7, $7000, $A82A;
  317.     {$ENDC}
  318. FUNCTION AudioGetTreble(ac: ComponentInstance; whichChannel: INTEGER; VAR Treble: INTEGER): ComponentResult;
  319.     {$IFC NOT GENERATINGCFM}
  320.     INLINE $2F3C, 6, 8, $7000, $A82A;
  321.     {$ENDC}
  322. FUNCTION AudioSetTreble(ac: ComponentInstance; whichChannel: INTEGER; Treble: INTEGER): ComponentResult;
  323.     {$IFC NOT GENERATINGCFM}
  324.     INLINE $2F3C, 4, 9, $7000, $A82A;
  325.     {$ENDC}
  326. FUNCTION AudioGetOutputDevice(ac: ComponentInstance; VAR outputDevice: Component): ComponentResult;
  327.     {$IFC NOT GENERATINGCFM}
  328.     INLINE $2F3C, 4, 10, $7000, $A82A;
  329.     {$ENDC}
  330. {This is routine is private to the AudioVision component.  It enables the watching of the mute key.}
  331. FUNCTION AudioMuteOnEvent(ac: ComponentInstance; muteOnEvent: INTEGER): ComponentResult;
  332.     {$IFC NOT GENERATINGCFM}
  333.     INLINE $2F3C, 2, 129, $7000, $A82A;
  334.     {$ENDC}
  335. CONST
  336.     uppSoundParamProcInfo = $000000D0; { FUNCTION (4 byte param): 1 byte result; }
  337.  
  338. FUNCTION NewSoundParamProc(userRoutine: SoundParamProcPtr): SoundParamUPP;
  339.     {$IFC NOT GENERATINGCFM }
  340.     INLINE $2E9F;
  341.     {$ENDC}
  342.  
  343. FUNCTION CallSoundParamProc(VAR pb: SoundParamBlockPtr; userRoutine: SoundParamUPP): BOOLEAN;
  344.     {$IFC NOT GENERATINGCFM}
  345.     INLINE $205F, $4E90;
  346.     {$ENDC}
  347.  
  348. {$ALIGN RESET}
  349. {$POP}
  350.  
  351. {$SETC UsingIncludes := SoundComponentsIncludes}
  352.  
  353. {$ENDC} {__SOUNDCOMPONENTS__}
  354.  
  355. {$IFC NOT UsingIncludes}
  356.  END.
  357. {$ENDC}
  358.